package gameObject.resources3D
{
	import assets.Asset;
	
	import away3d.entities.Mesh;
	
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class EnemyResource extends ResourceBase
	{
		private var _mesh:GameMesh;
		private var _url:String;
		
		public function EnemyResource(id:uint)
		{
			super();
			
			_id = id;
		}
		
		public function get mesh():GameMesh
		{
			return _mesh;
		}

		override public function load():void
		{
			if(_id>=0 && !_mesh)
			{
				_url = Global.assetPath+"models/enemy/enemy_"+String(_id)+"_skm.xml";
				_mesh = new GameMesh(_url);
				_mesh.addEventListener(Event.COMPLETE,meshLoaded);
				_mesh.load();
			}
		}
		
		private function meshLoaded(e:Event):void
		{
			
			_mesh.removeEventListener(Event.COMPLETE,meshLoaded);
			addChild(_mesh);
			
			dispatchEvent(new Event(Event.COMPLETE));
		}
		
	}
}